﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:vm="clr-namespace:GlobalizationTools.ViewModel"
                    xmlns:ui="clr-namespace:GlobalizationTools.UI">

    <LinearGradientBrush x:Key="GradientBackgroundBrush"
                         StartPoint="0,0"
                         EndPoint="1,0">
        <LinearGradientBrush.GradientStops>
            <GradientStop Color="{DynamicResource {x:Static SystemColors.ControlColorKey}}"
                          Offset="0" />
            <GradientStop Color="{DynamicResource {x:Static SystemColors.ControlLightLightColorKey}}"
                          Offset="1" />
        </LinearGradientBrush.GradientStops>
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="TabHeaderSelectedBackgroundBrush"
                         StartPoint="0,0"
                         EndPoint="0,1">
        <LinearGradientBrush.GradientStops>
            <GradientStop Color="{DynamicResource {x:Static SystemColors.ControlLightLightColorKey}}"
                          Offset="0" />
            <GradientStop Color="{DynamicResource {x:Static SystemColors.ControlColorKey}}"
                          Offset="1" />
        </LinearGradientBrush.GradientStops>
    </LinearGradientBrush>

    <Color x:Key="TabItem_ForegroundColor_Base">#4971A3</Color>

    <SolidColorBrush x:Key="TabItemCloseButtonNormalForegroundBrush"
                       Color="{StaticResource TabItem_ForegroundColor_Base}"/>
    <SolidColorBrush x:Key="TabItemCloseButtonHoverForegroundBrush"
                       Color="White"/>

    <LinearGradientBrush x:Key="TabItemCloseButtonNormalBackgroundBrush" 
                           StartPoint="0,0" EndPoint="1,0">
        <GradientBrush.GradientStops>
            <GradientStopCollection>
                <GradientStop Color="#5FFF" Offset="0.0"/>
                <GradientStop Color="#5CCC" Offset="1.0"/>
            </GradientStopCollection>
        </GradientBrush.GradientStops>
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="TabItemCloseButtonNormalBorderBrush" 
                           StartPoint="0,0" EndPoint="1,1">
        <GradientBrush.GradientStops>
            <GradientStopCollection>
                <GradientStop Color="#5CCC" Offset="0.0"/>
                <GradientStop Color="#5444" Offset="1.0"/>
            </GradientStopCollection>
        </GradientBrush.GradientStops>
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="TabItemCloseButtonHoverBackgroundBrush" 
                           StartPoint="0,1" EndPoint="1,0">
        <GradientBrush.GradientStops>
            <GradientStopCollection>
                <GradientStop Color="#FFDF2B1E" Offset="0.0"/>
                <GradientStop Color="#FFA41F00" Offset="1.0"/>
            </GradientStopCollection>
        </GradientBrush.GradientStops>
    </LinearGradientBrush>

    <Style TargetType="{x:Type TreeViewItem}"
           x:Key="SolutionTreeViewItemStyle">
        <Setter Property="ui:CreateCommandContext.Context"
                Value="{Binding}" />
        <Setter Property="IsExpanded"
                Value="{Binding IsExpanded, Mode=TwoWay}" />
        <Setter Property="IsSelected"
                Value="{Binding IsSelected, Mode=TwoWay}" />
        <Setter Property="Padding"
                Value="2,1,3,1" />
    </Style>

    <Style TargetType="{x:Type TabControl}">
        <Setter Property="TextElement.Foreground"
                Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
        <Setter Property="Control.HorizontalContentAlignment"
                Value="Center" />
        <Setter Property="Control.VerticalContentAlignment"
                Value="Center" />
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabControl}">
                    <Grid ClipToBounds="True"
                          SnapsToDevicePixels="True"
                          KeyboardNavigation.TabNavigation="Local">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Name="ColumnDefinition0" />
                            <ColumnDefinition Width="0"
                                              Name="ColumnDefinition1" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"
                                           Name="RowDefinition0" />
                            <RowDefinition Height="*"
                                           Name="RowDefinition1" />
                        </Grid.RowDefinitions>
                        <TabPanel IsItemsHost="True"
                                  Name="HeaderPanel"
                                  Margin="4,2,4,0"
                                  KeyboardNavigation.TabIndex="1"
                                  Panel.ZIndex="1"
                                  Grid.Column="0"
                                  Grid.Row="0" />
                        <Border BorderThickness="{TemplateBinding Border.BorderThickness}"
                                BorderBrush="{TemplateBinding Border.BorderBrush}"
                                Background="{TemplateBinding Panel.Background}"
                                Name="ContentPanel"
                                KeyboardNavigation.TabIndex="2"
                                KeyboardNavigation.TabNavigation="Local"
                                KeyboardNavigation.DirectionalNavigation="Contained"
                                Grid.Column="0"
                                Grid.Row="1">
                            <ContentPresenter Content="{TemplateBinding TabControl.SelectedContent}"
                                              ContentTemplate="{TemplateBinding TabControl.SelectedContentTemplate}"
                                              ContentStringFormat="{TemplateBinding TabControl.SelectedContentStringFormat}"
                                              ContentSource="SelectedContent"
                                              Name="PART_SelectedContentHost"
                                              Margin="{TemplateBinding Control.Padding}"
                                              SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="TabControl.TabStripPlacement"
                                 Value="Bottom">
                            <Setter Property="Grid.Row"
                                    TargetName="HeaderPanel"
                                    Value="1" />
                            <Setter Property="Grid.Row"
                                    TargetName="ContentPanel"
                                    Value="0" />
                            <Setter Property="RowDefinition.Height"
                                    TargetName="RowDefinition0"
                                    Value="*" />
                            <Setter Property="RowDefinition.Height"
                                    TargetName="RowDefinition1"
                                    Value="Auto" />
                            <Setter Property="FrameworkElement.Margin"
                                    TargetName="HeaderPanel"
                                    Value="4,0,4,2" />
                        </Trigger>
                        <Trigger Property="TabControl.TabStripPlacement"
                                 Value="Left">
                            <Setter Property="Grid.Row"
                                    TargetName="HeaderPanel"
                                    Value="0" />
                            <Setter Property="Grid.Row"
                                    TargetName="ContentPanel"
                                    Value="0" />
                            <Setter Property="Grid.Column"
                                    TargetName="HeaderPanel"
                                    Value="0" />
                            <Setter Property="Grid.Column"
                                    TargetName="ContentPanel"
                                    Value="1" />
                            <Setter Property="ColumnDefinition.Width"
                                    TargetName="ColumnDefinition0"
                                    Value="Auto" />
                            <Setter Property="ColumnDefinition.Width"
                                    TargetName="ColumnDefinition1"
                                    Value="*" />
                            <Setter Property="RowDefinition.Height"
                                    TargetName="RowDefinition0"
                                    Value="*" />
                            <Setter Property="RowDefinition.Height"
                                    TargetName="RowDefinition1"
                                    Value="0" />
                            <Setter Property="FrameworkElement.Margin"
                                    TargetName="HeaderPanel"
                                    Value="2,4,0,4" />
                        </Trigger>
                        <Trigger Property="TabControl.TabStripPlacement"
                                 Value="Right">
                            <Setter Property="Grid.Row"
                                    TargetName="HeaderPanel"
                                    Value="0" />
                            <Setter Property="Grid.Row"
                                    TargetName="ContentPanel"
                                    Value="0" />
                            <Setter Property="Grid.Column"
                                    TargetName="HeaderPanel"
                                    Value="1" />
                            <Setter Property="Grid.Column"
                                    TargetName="ContentPanel"
                                    Value="0" />
                            <Setter Property="ColumnDefinition.Width"
                                    TargetName="ColumnDefinition0"
                                    Value="*" />
                            <Setter Property="ColumnDefinition.Width"
                                    TargetName="ColumnDefinition1"
                                    Value="Auto" />
                            <Setter Property="RowDefinition.Height"
                                    TargetName="RowDefinition0"
                                    Value="*" />
                            <Setter Property="RowDefinition.Height"
                                    TargetName="RowDefinition1"
                                    Value="0" />
                            <Setter Property="FrameworkElement.Margin"
                                    TargetName="HeaderPanel"
                                    Value="0,4,2,4" />
                        </Trigger>
                        <Trigger Property="UIElement.IsEnabled"
                                 Value="false">
                            <Setter Property="TextElement.Foreground"
                                    Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="TabItemCloseButtonStyle" TargetType="{x:Type Button}">
        <Setter Property="Height" Value="14"/>
        <Setter Property="Width" Value="14"/>
        <Setter Property="Cursor" Value="Hand"/>
        <Setter Property="Focusable" Value="False"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Border x:Name="ButtonBorder" 
                          CornerRadius="2"
                          BorderThickness="1"
                          Background="{StaticResource TabItemCloseButtonNormalBackgroundBrush}"
                          BorderBrush="{StaticResource TabItemCloseButtonNormalBorderBrush}">
                        <Path x:Name="ButtonPath"
                              Margin="2"
                              Stroke="{StaticResource TabItemCloseButtonNormalForegroundBrush}"
                              StrokeThickness="2"
                              StrokeStartLineCap="Round"
                              StrokeEndLineCap="Round"
                              Stretch="Uniform"
                              VerticalAlignment="Center"
                              HorizontalAlignment="Center">
                            <Path.Data>
                                <Geometry>M0,0 L10,10 M0,10 L10,0</Geometry>
                            </Path.Data>
                        </Path>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="ButtonBorder"
                          Property="Background"
                          Value="{StaticResource
                             TabItemCloseButtonHoverBackgroundBrush}" />
                            <Setter TargetName="ButtonPath"
                          Property="Stroke"
                          Value="{StaticResource
                             TabItemCloseButtonHoverForegroundBrush}"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Visibility" Value="Collapsed"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <Style TargetType="{x:Type TabItem}">
        <Setter Property="ui:CreateCommandContext.Context"
                Value="{Binding}" />
        <Setter Property="TextElement.Foreground"
                Value="#FF000000" />
        <Setter Property="Control.Padding"
                Value="6,2,6,2" />
        <Setter Property="Border.BorderBrush"
                Value="#FF8C8E94" />
        <Setter Property="Panel.Background"
                Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
        <Setter Property="Control.HorizontalContentAlignment"
                Value="Stretch" />
        <Setter Property="Control.VerticalContentAlignment"
                Value="Stretch" />
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabItem}">
                    <Grid SnapsToDevicePixels="True">
                        <Border BorderThickness="1,1,1,0"
                                Padding="{TemplateBinding Control.Padding}"
                                BorderBrush="{TemplateBinding Border.BorderBrush}"
                                Background="{TemplateBinding Panel.Background}"
                                Name="Bd" CornerRadius="4,4,0,0">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                </Grid.ColumnDefinitions>
                                <ContentPresenter RecognizesAccessKey="True"
                                              Content="{TemplateBinding HeaderedContentControl.Header}"
                                              ContentTemplate="{TemplateBinding HeaderedContentControl.HeaderTemplate}"
                                              ContentStringFormat="{TemplateBinding HeaderedContentControl.HeaderStringFormat}"
                                              ContentSource="Header"
                                              Name="Content"
                                              HorizontalAlignment="Stretch"
                                              VerticalAlignment="Center"
                                              SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
                                <Button Style="{StaticResource TabItemCloseButtonStyle}"
                                        Command="vm:TabControlItemViewModel.CloseCommand"
                                  Grid.Column="1"
                                  VerticalAlignment="Center"
                                  Margin="4,0,0,0"/>
                            </Grid>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="UIElement.IsMouseOver"
                                 Value="true">
                            <Setter Property="Panel.Background"
                                    TargetName="Bd"
                                    Value="{DynamicResource {x:Static SystemColors.ControlLightLightBrushKey}}" />
                        </Trigger>
                        <Trigger Property="Selector.IsSelected"
                                 Value="true">
                            <Setter Property="Panel.ZIndex"
                                    Value="1" />
                            <Setter Property="Panel.Background"
                                    TargetName="Bd"
                                    Value="{DynamicResource TabHeaderSelectedBackgroundBrush}" />
                            <Setter Property="TextElement.FontWeight"
                                    TargetName="Content"
                                    Value="SemiBold" />
                        </Trigger>
                        <Trigger Property="TabItem.TabStripPlacement"
                                 Value="Bottom">
                            <Setter Property="Border.BorderThickness"
                                    TargetName="Bd"
                                    Value="1,0,1,1" />
                        </Trigger>
                        <Trigger Property="TabItem.TabStripPlacement"
                                 Value="Left">
                            <Setter Property="Border.BorderThickness"
                                    TargetName="Bd"
                                    Value="1,1,0,1" />
                        </Trigger>
                        <Trigger Property="TabItem.TabStripPlacement"
                                 Value="Right">
                            <Setter Property="Border.BorderThickness"
                                    TargetName="Bd"
                                    Value="0,1,1,1" />
                        </Trigger>
                        <Trigger Property="Selector.IsSelected"
                                 Value="true">
                            <Setter Property="FrameworkElement.Margin"
                                    Value="-1" />
                            <Setter Property="FrameworkElement.Margin"
                                    TargetName="Content"
                                    Value="1" />
                        </Trigger>
                        <Trigger Property="UIElement.IsEnabled"
                                 Value="false">
                            <Setter Property="Panel.Background"
                                    TargetName="Bd"
                                    Value="#FFF4F4F4" />
                            <Setter Property="Border.BorderBrush"
                                    TargetName="Bd"
                                    Value="#FFC9C7BA" />
                            <Setter Property="TextElement.Foreground"
                                    Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}">
                            </Setter>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="{x:Type ComboBoxItem}">
        <Setter Property="Padding"
                Value="4,1,4,1" />
    </Style>

    <DataTemplate DataType="{x:Type vm:TabControlItemViewModel}">
        <vm:MultiResourceViewer />
    </DataTemplate>

    <DataTemplate x:Key="TabItemTemplate">
        <TextBlock Text="{Binding Name}"
                   ToolTip="{Binding Resource.Include}" />
    </DataTemplate>

    <HierarchicalDataTemplate DataType="{x:Type vm:TreeViewSolutionViewModel}"
                              ItemsSource="{Binding Children}">
        <StackPanel Orientation="Horizontal">
            <Image Width="16"
                   Height="16"
                   Margin="0,0,3,0"
                   Source="Images\Solution.png" />
            <TextBlock Text="{Binding Name}"
                       ToolTip="{Binding Solution.FilePath}" />
        </StackPanel>
    </HierarchicalDataTemplate>
    <HierarchicalDataTemplate DataType="{x:Type vm:TreeViewProjectViewModel}"
                              ItemsSource="{Binding Children}">
        <StackPanel Orientation="Horizontal">
            <Image Width="16"
                   Height="16"
                   Margin="0,0,3,0"
                   Source="Images\Project.png" />
            <TextBlock Text="{Binding Name}"
                       ToolTip="{Binding Project.FilePath}" />
        </StackPanel>
    </HierarchicalDataTemplate>
    <HierarchicalDataTemplate DataType="{x:Type vm:TreeViewFolderViewModel}"
                              ItemsSource="{Binding Children}">
        <StackPanel Orientation="Horizontal">
            <Image Width="16"
                   Height="16"
                   Margin="0,0,3,0"
                   Source="Images\Folder.png" />
            <TextBlock Text="{Binding Name}" />
        </StackPanel>
    </HierarchicalDataTemplate>
    <HierarchicalDataTemplate DataType="{x:Type vm:TreeViewResourceViewModel}"
                              ItemsSource="{Binding Children}">
        <StackPanel Orientation="Horizontal">
            <Image Width="16"
                   Height="16"
                   Margin="0,0,3,0"
                   Source="Images\Resource.png" />
            <TextBlock Text="{Binding Name}" ToolTip="{Binding FileName}" />
        </StackPanel>
    </HierarchicalDataTemplate>

</ResourceDictionary>